﻿//xiaohui 20210330
function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
	return false;
}
function get_oauth_info(url,fun) {
	//授权地址参数ulr,授权回调参数fun
	var searchURL = window.location.search;  
	var backUrl = encodeURI(window.location.href)
	//var finurl = searchURL.split("?uniqid=")[1];
	//var ajaxurl=url;//逸明服务号授权地址
	console.log("授权接口url:"+url);
	var ddmid
		$.ajax({
			url: url,
			data: {back_url:backUrl},
			type: 'GET',
			dataType: 'json',

			success: function(res) {
				console.log(res.return_msg);
				console.log(res.return_data.mid);
				ddmid = res.return_data.mid
				console.log("res.return_data:"+res.return_data);
				if(res.return_code == 'success') 
				{
					_mid = getQueryVariable("mid");
					fun(res.return_data)
				}else{
					window.location.href = res.return_data;
				}
			}
		});
		
}
//get_oauth_info();
